<template>
    <div>
        <h1>房价计划添加</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <th align="right">房价计划名称</th>
                    <th><input type="text" v-model="queryinfo.PName"></th>
                </tr>
                <tr>
                    <th align="right">门店</th>
                    <th>
                        <select v-model="queryinfo.SName">
                            <option value="">请选择</option>
                            <option value="河北石家庄">河北石家庄</option>
                            <option value="广州白云山">广州白云山</option>
                            <option value="北京昌平区">北京昌平区</option>
                        </select>
                    </th>
                </tr>
                <tr>
                    <th align="right">房型</th>
                    <th>
                        <select v-model="queryinfo.HName">
                            <option value="">请选择</option>
                            <option :value="item.HName" v-for="item in list">{{ item.HName }}</option>
                        </select>
                    </th>
                </tr>
                <tr>
                    <th align="right">房型价格</th>
                    <th><input type="text" v-model="queryinfo.PPrice"></th>
                </tr>
                <tr>
                    <th align="right">房型数量</th>
                    <th><input type="text" v-model="queryinfo.PNumber"></th>
                </tr>
                <tr>
                    <th align="right">状态</th>
                    <th>
                        <input type="radio" name="state" :value="1" v-model="queryinfo.PState">开启
                        <input type="radio" name="state" :value="0" v-model="queryinfo.PState">禁用
                    </th>
                </tr>
                <tr>
                    <th align="right">早餐数量</th>
                    <th><input type="text" v-model="queryinfo.BreakfastNum"></th>
                </tr>
                <tr>
                    <th align="right">开始时间</th>
                    <th><input type="date" v-model="queryinfo.BeginTime"></th>
                </tr>
                <tr>
                    <th align="right">结束时间</th>
                    <th><input type="date" v-model="queryinfo.EndTime"></th>
                </tr>
                <tr>
                    <th align="right"></th>
                    <th><input type="button" value="增加" class="btn btn-primary" @click="ok"></th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
import { useAdminStare } from '@/stores/admin';
const adc = useAdminStare();
const route = useRoute()
const router = useRouter()

let queryinfo:any=reactive({
  "PName": "",
  "SName": "",
  "HName": "",
  "PPrice": "",
  "PNumber": "",
  "PState": 1,
  "BreakfastNum": "",
  "BeginTime": "",
  "EndTime": "",
})

let list:any=ref([])

onMounted(()=>{
    getist()
})

const getist=()=>{
    axios({
        url:'/api/House/GetHouseTypes',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        list.value=res.data
    })
}

const ok=()=>{
    axios({
        url:'/api/House/AddHousePlan',
        method:'post',
        data:queryinfo
    })
    .then((res)=>{
        console.log(res);
        if(res.data>0){
            alert("增加成功")
        }
        else{
            alert("增加失败")
            return
        }
    })
}


</script>

<style scoped>

</style>